package com.smartlifev30.baiwei.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.smartlifev30.R;
import com.smartlifev30.baiwei.bean.Linkage;
import com.smartlifev30.baiwei.view.recyclerViewComponent.BaseAdapter;
import com.smartlifev30.baiwei.view.recyclerViewComponent.BaseViewHolder;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 *
 * @author tys
 * @date 2018/8/20
 */

public class LinkageAdapter extends BaseAdapter<Linkage, LinkageAdapter.ViewHolder> {
    public LinkageAdapter(Context context, ArrayList<Linkage> linkages) {
        super(context, linkages);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(context)
                .inflate(R.layout.linkage_item, parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return 21;
    }

    class ViewHolder extends BaseViewHolder {
        @BindView(R.id.linkage_item_switch_button)
        SwitchCompat switchButton;

        ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            switchButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
                Toast.makeText(context, isChecked?"開":"关" +getAdapterPosition(), Toast.LENGTH_SHORT).show();
            });
        }
    }
}
